//
//  LoginInPutWithHideView.m
//  HaiGeEr_Student
//
//  Created by liuchen on 2018/9/9.
//  Copyright © 2018年 海格尔. All rights reserved.
//

#import "LoginInPutWithHideView.h"
@interface LoginInPutWithHideView()
@property (nonatomic,weak) UIButton *hideBtn;
@end

@implementation LoginInPutWithHideView

- (void)addHideBtn{
    
    self.textField.secureTextEntry = YES;
    UIButton *hideBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [hideBtn setImageEdgeInsets:UIEdgeInsetsMake(5*SCALEUNIT, 5*SCALEUNIT, 5*SCALEUNIT, 5*SCALEUNIT)];
    [hideBtn setImage:[UIImage imageNamed:@"7-1-8"] forState:UIControlStateNormal];
    [hideBtn setImage:[UIImage imageNamed:@"7-1-7"] forState:UIControlStateSelected];
    [hideBtn addTarget:self action:@selector(hideChange:) forControlEvents:UIControlEventTouchUpInside];
    _hideBtn = hideBtn;
    [self addSubview:self.hideBtn];
    
    WS(ws);
    [self.hideBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(ws.textField);
        make.right.mas_equalTo(ws);
        make.size.mas_equalTo(CGSizeMake(40*SCALEUNIT, 27*SCALEUNIT));
    }];
}

#pragma mark ==========切换明秘密吗==========
- (void)hideChange:(UIButton *)btn{
    btn.selected = !btn.selected;
    if (btn.selected) {
        self.textField.secureTextEntry = NO;
    }else{
        self.textField.secureTextEntry = YES;
    }
}



@end
